package com.mywork;

import com.mywork.service.UserInterface;
import com.mywork.service.UserService;
import com.spring.MyApplicationContext;

import java.io.UnsupportedEncodingException;

public class Test {
    public static void main(String[] args) throws UnsupportedEncodingException {
//        获得扫描路径 路径下有哪些类被Controller注解修饰
        MyApplicationContext applicationContext = new MyApplicationContext(AppConfig.class);
//        判断哪个类的Controller中的属性值和传入的相等 如果相等则创建对象
//        创建对象的过程中进行依赖注入 和判断是否实现了BeanNameAware接口
//        如果实现了 则给对应的属性赋值
        UserInterface userService1 = (UserInterface) applicationContext.getBean("userService");
        UserInterface userService2 = (UserInterface) applicationContext.getBean("userService");
        UserInterface userService3 = (UserInterface) applicationContext.getBean("userService");

        System.out.println(userService1);
        System.out.println(userService2);
        System.out.println(userService3);
        userService1.test();  //1. 代理对象  2. 业务test
    }

}
